'use strict';

module.exports = app => {
    const {router, controller, middleware} = app;
    router.post('/miniapp/upload',  controller.common.upload.uploadToQiNiu);
    router.post('/miniapp/lat', controller.miniapp.user.getAddressByLat);

    // 用户相关路由组
    router.group({name: 'user', prefix: '/miniapp'}, router => {
        // 浏览记录
        router.get('/user/history', controller.miniapp.user.getHistory);
        router.get('/user/cover_shift_history', controller.miniapp.user.getCoverShiftHistory);
        router.get('/user/count_stat', controller.miniapp.user.getCountState);
        router.get('/employer', controller.miniapp.user.getEmployerInfo);
        router.put('/employer/info', controller.miniapp.user.updateEmployerInfo);
        router.post('/user/user_verify', controller.miniapp.user.userVerify);
        router.post('/user/employer_verify', controller.miniapp.user.employerVerify);
        router.get('/employer/job_opening', controller.miniapp.user.getUserJobOpening); // 推荐
        router.get('/user/job_opening', controller.miniapp.jobOpening.userJobList);  // 推荐

        router.post('/login/weapp', controller.miniapp.user.loginByWeapp);
        router.post('/login/phone', controller.miniapp.user.loginByPhone);
        router.post('/getAccessToken', controller.miniapp.user.getAccessToken);

        router.post('/sms/code', controller.miniapp.user.sendSmsCode);
        router.post('/resume', controller.miniapp.user.saveResume);
        // 简历工作经验路由
        router.post('/resume/experience', controller.miniapp.user.addExperience);
        router.get('/resume/experiences', controller.miniapp.user.getExperiences);
        router.get('/resume/experiences/:id', controller.miniapp.user.getExperienceDetail);
        router.get('/resume', controller.miniapp.user.getResume);
        router.put('/resume/experience/:id', controller.miniapp.user.updateExperience);
        router.delete('/resume/experience/:id', controller.miniapp.user.deleteExperience);

    });
    // 发票抬头
    router.group({name: 'invoice_title', prefix: '/miniapp'}, router => {
        router.resources("invoice_title", "/invoice_title", controller.miniapp.invoiceTitle);
    })

    // 顶班求职和招聘
    router.group({name: 'cover_shift', prefix: '/miniapp'}, router => {
        router.put("/cover_shift/status/:id", controller.miniapp.coverShift.updateStatus);
        router.get("/cover_shift/view/:id", controller.miniapp.coverShift.userView);
        router.get("/cover_shift/collect/:id", controller.miniapp.coverShift.userCollect);
        router.resources("cover_shift", "/cover_shift", controller.miniapp.coverShift);

    })


    // 企业职位发布
    router.group({name: 'job_opening', prefix: '/miniapp'}, router => {
        router.get('/my_job_opening', controller.miniapp.jobOpening.myJobList);  // 职位管理里面的接口
        router.post("/job_opening_employer", controller.miniapp.jobOpening.employerCreate);
        router.put("/job_opening_employer", controller.miniapp.jobOpening.employerUpdate);
        router.put("/job_opening_employer/status/:id", controller.miniapp.jobOpening.employerUpdateStatus);
        router.get("/job_opening_employer/:id", controller.miniapp.jobOpening.employerDetail);
        router.get("/job_opening_user/:id", controller.miniapp.jobOpening.userJobDetail);
        // 给企业推荐发布的求职
        router.get("/job_opening_employer", controller.miniapp.jobOpening.employerJobList);
        // 给用户推荐的企业招聘
        // router.get("/job_opening_user", controller.miniapp.jobOpening.userJobList);
        //企业收藏或浏览
        router.get("/job_opening_user/view/:id", controller.miniapp.jobOpening.userJobView);
        router.get("/job_opening_user/collect/:id", controller.miniapp.jobOpening.userJobCollect);

    });

    // 公告
    router.group({name: 'notices', prefix: '/miniapp'}, router => {
        // router.resources("notices", "/notices", controller.admin.notice);
        router.get("/notices", controller.miniapp.notice.index);
        router.get("/notices/:id", controller.admin.notice.detail);
    });

    // 公告
    router.group({name: 'ads', prefix: '/miniapp'}, router => {
        router.get("/ads", controller.miniapp.ads.index);
    });
    //
    router.group({name: 'help_center', prefix: '/miniapp'}, router => {
        router.get("/help_center", controller.miniapp.helpCenter.index);
        router.get("/help_center/:id", controller.miniapp.helpCenter.detail);
    });
    // 岗位
    router.group({name: 'position', prefix: '/miniapp'}, router => {
        router.get('/position', controller.miniapp.position.index);
        router.get('/position/search', controller.miniapp.position.search);
    });
    // 文章相关路由组
    router.group({name: 'article', prefix: '/miniapp'}, router => {
        router.post('/getArticleByType', controller.miniapp.article.getArticleByType);
    });

    // 字典查询
    router.group({name: 'dict', prefix: '/miniapp'}, router => {
        router.get('/dict/:key', controller.admin.dictionaryDetail.getDictDetailList);
        router.get('/dicts/:key', controller.admin.dictionaryDetail.getDictDetailLists);
    });
};
